package com.linedata.acq.metier.norme.fmb;

import com.linedata.acq.utils.fmb.Utils;

import oracle.forms.jdapi.FormModule;
import oracle.forms.jdapi.JdapiIterator;
import oracle.forms.jdapi.Window;

public class GWIN_FMB {

	private Utils		utils	= new Utils();
	private FormModule	fmb;

	public GWIN_FMB(FormModule fmb) {
		this.fmb = fmb;
	}

	private String	error	= "";

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error += error;
	}

	/**
	 * EKFR008_1 :: Le nom des windows est PAGE_n
	 * 
	 * @param fmb
	 */
	public void nomWindow() {

		for (JdapiIterator windows = fmb.getWindows(); windows.hasNext();) {

			Window window = (Window) windows.next();

			if (window.getName().startsWith("PAGE_")) {
				try {
					Integer.parseInt(utils.Decouper(window.getName(), "_", 1));
				} catch (NumberFormatException nfe) {
					this.setError("\tEKFR008_1 : " + window.getName() + "\n");
				}
			} else
				this.setError("\tEKFR008_1 : " + window.getName() + "\n");
		}

	}

	@Override
	public String toString() {
		return this.getError();
	}
}
